package com.heima.pojo;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisOperations;

@Configuration
@ConditionalOnClass(RedisOperations.class)
public class UserConfig {


    /*
        @ConditionalOnClass(RedisOperations.class)
            总条件 当存在RedisOperations的字节码文件时创建
        @ConditionalOnMissingBean(name = {"redisTemplate"})
            且满足 没有redisTemplate的bean对象时创建
    */
    @Bean
    @ConditionalOnMissingBean(name = {"redisTemplate"})
    public User user(){
        return new User();
    }

}
